package protocol;

import java.util.Vector;

public class CommandRelay {
	
	private Vector<Cmd> inCmds;
	private Vector<Cmd> outCmds;

	
	public CommandRelay() {
		inCmds = new Vector<Cmd>();
		outCmds = new Vector<Cmd>();		
	}
	
	
	public synchronized void addInCmd(Cmd command) {
		inCmds.add(command);
	}
		
	public synchronized Cmd getInCmd() {
		if (inCmds.isEmpty()) {
			return null;
		}
		else {
			Cmd command = inCmds.firstElement();
			inCmds.removeElementAt(0);
			return command;
		}
	}
	
	public synchronized void addOutCmd(Cmd command) {
		outCmds.add(command);
	}
	
	public synchronized Cmd getOutCmd() {
		if (outCmds.isEmpty()) {
			return null;
		}
		else {
			Cmd command = outCmds.firstElement();
			outCmds.removeElementAt(0);
			return command;
		}
	}
}
